import { createRouter, createWebHashHistory } from 'vue-router';

const routes = [
  {
    path: "/",
    redirect: '/largeScreen'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/pages/login.vue'),
  },
  {
    path: '/largeScreen',
    name: 'largeScreen',
    component: () => import('@/views/largeScreen/index.vue'),
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});
router.beforeEach((to, from, next) => {
  if (to.path == '/login') {
    return next();
  }
  if (sessionStorage.getItem("UserInfo")) {
    return next()
  } else {
    return next('/login')
  }
  next()
})
export default router;